package com.apex.service.serviceImpl;

import com.apex.dto.ClientDTO;
import com.apex.mapper.ClientMapper;
import com.apex.pojo.Client;
import com.apex.pojo.ClientDetail;
import com.apex.service.ClientService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author George
 * @since 2023-06-13
 */
@Service
public class ClientServiceImpl extends ServiceImpl<ClientMapper, Client> implements ClientService {


    @Resource
    private ClientMapper clientMapper;


    @Override
    public List<Client> ClientQuery() {

        return clientMapper.selectList(null);
    }
    //证件类型

    @Override
    public Client ClientQueryById(String id) {
        return clientMapper.selectById(id);
    }

    @Override
    public List<ClientDTO> getClientByIdWithDetail(String id) {
        MPJLambdaWrapper<Client> wrapper = new MPJLambdaWrapper<Client>()
                .selectAll(Client.class)//查询user表全部字段
                .select( ClientDetail::getClientDetailDocumenttype
//                        证件号
                        ,ClientDetail::getClientDetailIdnumber
//                        银行名称
                        ,ClientDetail::getClientDetailBank
//                        银行卡号
                        ,ClientDetail::getClientDetailCardnumber
//                        银行网点
                        ,ClientDetail::getClientDetailBankbranches
//                        生日
                        ,ClientDetail::getClientDetailBirthday
//                        佣金等级
                        ,ClientDetail::getClientDetailCommissionvip
//                        备注
                        ,ClientDetail::getClientDetailMemo
//                        地址
                        ,ClientDetail::getClientDetailAddress)
                .leftJoin(ClientDetail.class, ClientDetail::getClientId, Client::getClientId)
                .eq(Client::getClientId,id);
        //调用clientMapper的selectJoinList方法，执行以上条件所述的查询操作，并将结果存储到List<Client>对象userList中
       return clientMapper.selectJoinList(ClientDTO.class, wrapper);
    }

}
